The present invention relates to an image processing method, an image processing apparatus, an image forming apparatus and a recording medium in which image data is transformed to spatial frequencies to obtain multiple frequency components, the obtained frequency components are processed, the processed frequency components are inversely transformed to image data, and the number of gray levels of the inversely transformed image data is decreased.
As a method for decreasing the number of gray levels of an image, for example, as a method for binarizing an image having 256 gray levels to obtain an image having 2 gray levels, a method for carrying out binarization by comparing the gray level value of an image with a threshold value, a dither method, an error diffusion method, etc. (Japanese Patent Application Laid-Open No. 2000-299783, Japanese Patent Application Laid-Open No. H06-189119 and Japanese Patent Application Laid-Open No. 2002-10085) are known.
FIG. 1 is a view showing an example of a 4×4 dither matrix that is used for the dither method in which an image having 256 gray levels is binarized. In the dither matrix, any one of threshold values in the range of 0 to 15 is set according to the position of each of 4×4 pixels. In the dither method, the gray level value of each of 4×4 pixels of input image data having 256 gray levels is compared with the threshold value having been set in the dither matrix and corresponding to each pixel. In the case that the gray level value is equal to or more than the threshold value, the gray level value is set at 255. In the case that the gray level value is less than the threshold value, the gray level value is set at 0. In this way, the image is binarized.
In the error diffusion method, a quantization error occurring when each pixel of input image data is binarized, that is, the difference between the gray level value of a pixel before binarization and the gray level value of the pixel after binarization is distributed to pixels not yet binarized. In the case that a pixel to be binarized is assumed to be a current pixel, the error (quantization error) between the gray level value of the current pixel and the gray level value thereof after binarization is added to the gray level values of the pixels not yet binarized and positioned in the vicinity of the current pixel, after weighing is carried out according to the relative position from the current pixel.
FIG. 2 is a view showing an example of a weighing coefficient matrix being used for the error diffusion method. In the example shown in FIG. 2, a 2×3 weighing coefficient matrix including a current pixel (IX, IY) is shown, wherein the horizontal direction, that is, the right direction in the figure, is assumed to be the X direction, and the vertical direction, that is, the downward direction in the figure, is assumed to be the Y direction. The weighing coefficient matrix designates the weighing coefficients of the lower left pixel, the lower pixel, the lower right pixel and the right pixel adjacent to the current pixel (IX, IY). For example, the gray level value of the current pixel (IX, IY) is compared with a threshold value. In the case that the gray level value is equal to or more than the threshold value, the gray level value of the current pixel (IX, IY) is set to 255. In the case that the gray level value is less than the threshold value, the gray level value of the current pixel (IX, IY) is set to 0. Next, the difference between the binarized gray level value, 255 or 0, and the gray level value of the current pixel (IX, IY) before binarization, that is, a quantization error, is distributed to the adjacent pixels before binarization, on the basis of the weighing coefficient matrix. However, because the pixel (IX−1, IY) on the left side of the current pixel (IX, IY) has already been quantized earlier than the current pixel (IX, IY), the quantization error is not distributed to the left pixel.
In the case that the quantization error is assumed to be Err, Err×( 7/16), Err×( 1/16), Err×( 5/16) and Err×( 3/16) are distributed to the four pixels (IX+1, IY), (IX+1, IY+1), (IX, IY+1) and (IX−1, IY+1) positioned adjacent to the current pixel (IX, IY), respectively. Because the quantization error components are distributed to the adjacent unprocessed pixels on the basis of the weighing coefficient matrix, the error diffusion method has an advantage of hardly causing moire patterns in binarized images in comparison with the dither method.
In addition, according to the method disclosed in Japanese Patent Application Laid-Open No. 2002-10085, image data is transformed to image data having spatial frequency components, and image halftone processing is carried out using the data transformed to halftone spatial frequency regions predetermined for the coefficients of the transformed spatial frequency components.